<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" /></title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}jp/1.css" />
<link rel="stylesheet" href="${aier_css_url}jc/chosen.css" >
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}index/fam-user-mana.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
</head>
<body style="background-color: #EEF2FB;">

	<div style="background-color: #EEF2FB;width: 100%;height: 700px;">

		<div id="tabs">
			<ul>
				<li><a href="#tabs-1">分派卡</a>
				</li>
			</ul>
			<div id="tabs-1" style="height: 500px;">
				<div class="d_content">
					这里是分配卡界面...
					<s:action name="proxy_choice" namespace="/zxadmin"
						executeResult="true"></s:action>
					<button onclick="notAssignCard();"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						role="button" aria-disabled="false">
						<span class="ui-button-text">显示未分配的卡</span>
					</button>
					
					<div class="clearfix" style="height: 200px;width: 200px;">
						<div id="assigncard" style="float: left;">
						</div>
						<div id=icCdate class="jqpage" style="float: left;width: 500px;height: 40px;">
						</div>
					</div>
					
					
					<div class="d_scnOut" style="margin-top: 20px;margin-left: -76px;">
						<div class="d_scname">
							<label>head:</label>
						</div>
						<div class="d_sctext">
							<input type="text" id="ichead" class="PY-input"/>
						</div>
					</div>
					<div class="d_scnOut" style="margin-top: -40px;margin-left: 170px;">
						<div class="d_scname">
							<label>icbody1:</label>
						</div>
						<div class="d_sctext">
							<input type="text" id="icbody1" class="PY-input"/>
						</div>
					</div>
					<div class="d_scnOut" style="margin-top: -40px;margin-left: 420px;">
						<div class="d_scname">
							<label>icbody2:</label>
						</div>
						<div class="d_sctext">
							<input type="text" id="icbody2" class="PY-input"/>
						</div>
					</div>
					<button onclick="cardSearch();"
						class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
						role="button" aria-disabled="false"
						style="margin-top: -80px;margin-left: 720px;">
						<span class="ui-button-text">分配</span>
					</button>
					<div id="haveAssgin"></div>
					<div id=icCdate1 class="jqpage"></div>
				</div>
			</div>
		</div>

	</div>


	<script type="text/javascript">
		$("#tabs").tabs();
		//查询分配卡
		function notAssignCard(p) {
			var fun = function(data) {
				var t = "";
				for ( var i = 0; i < data.icCards.length; i++) {
					var ics = data.icCards[i];

					t += "<div>" + ics.ichead + ics.icbody + ics.icfoot
							+ "</div>";
				}
				$("#icCdate").pager({
					pagenumber : data.page,
					pagecount : data.page_count,
					buttonClickCallback : function(page) {
						notAssignCard(page);
					}
				});
				$("#assigncard").html(t);
			};

			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/adminassign_searchAssignCard${aier_suffix}"),
					fun, {
						"page" : p,
					});
		}
		//为未分配的卡添加代理
		function cardSearch() {
			var fun = function(data) {
				if (data.s == 1) {
					alert("分派成功");
					searchAssignedCard();
					notAssignCard();
				} else {
					alert("分派失败");
				}
			};
			exeAjax(
					ajaxUrl("${aier_url}zxadminjs/adminassign_insertCardProxy${aier_suffix}"),
					fun, {
						"ichead" : $("#ichead").val(),
						"icbody1" : $("#icbody1").val(),
						"icbody2" : $("#icbody2").val(),
						"pid" : s_pid,

					});
		}
		
		$(document).ready(function() {
		    if ("${account}" != null && "${account}" != "") {
		        $("#account").val("${account}");
		        checkAccount();
		    }
		});
        //查询已分配的卡
        function searchAssignedCard(p) {
            if(isnull(s_pid)){
                $().message("请指定代理商！");
                return
            }
            var fun = function(data) {
                var r = "<span>";
                for ( var i = 0; i < data.icCards.length; i++) {
                    r += "<span>" + data.icCards[i].ichead + "</span><span>"
                            + data.icCards[i].icbody + "</span><br>";
                }
                $("#icCdate1").pager({
                    pagenumber : data.page,
                    pagecount : data.page_count,
                    buttonClickCallback : function(page) {
                        searchAssignedCard(page);
                    }
                });
                
                $("#haveAssgin").html(r);
            };

            exeAjax(
                    ajaxUrl("${aier_url}${aier_urijs}adminrecover_searchAssignCard${aier_suffix}"),
                    fun, {
                        "page" : p,
                        "pid" : s_pid,
                    });
        }             
	</script>
</body>
</html>